//
//  main.m
//  NSNumber
//
//  Created by wenjim on 17/10/25.
//  Copyright © 2017年 WenJim. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    
    int age = 25;
    double number = 5.5;
    int value = 6;
    
//    NSArray * arr = @[age,number,value];
    // 1.将基本数据类型转换为对象类型
    NSNumber * ageN = [NSNumber numberWithInt:age];
    NSNumber * numberN = [NSNumber numberWithDouble:number];
    NSNumber * valueN = [NSNumber numberWithInt:value];
    
    NSArray * arr = @[ageN,numberN,valueN];
    NSLog(@"arr = %@",arr);
    
    
    // 2.将对象类型转换为基本数据类型
    int temp  = [ageN intValue];
    double temp2 = [numberN doubleValue];
    NSLog(@"temp = %i, temp2 = %f",temp,temp2);
    
    
    // 3.基本数据类型转换对象类型 简写
    // 注意：如果传入的是变量，那么必须在@后面写上()；如果传入的是常量，那么@后面的()可以省略
    NSNumber * temp3 = @(age);
    NSNumber * temp4 = @(number);
    
    NSNumber * temp5 = @10.10;
    NSLog(@"temp3 = %@,temp4 = %@,temp5 = %@",temp3,temp4,temp5);
    
    
    
    
    return 0;
}
